<?php require_once('Connections/User_Information.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
{
  if (PHP_VERSION < 6) {
    $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
  }

  $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

  switch ($theType) {
    case "text":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;    
    case "long":
    case "int":
      $theValue = ($theValue != "") ? intval($theValue) : "NULL";
      break;
    case "double":
      $theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
      break;
    case "date":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;
    case "defined":
      $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
      break;
  }
  return $theValue;
}
}

$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
  $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
}

if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form")) {
  $insertSQL = sprintf("INSERT INTO users (Username, Password, Firstname, Lastname, MIddlename, Address, Birthday, Contact, Email) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s)",
                       GetSQLValueString($_POST['username'], "text"),
                       GetSQLValueString($_POST['password'], "text"),
                       GetSQLValueString($_POST['firstname'], "text"),
                       GetSQLValueString($_POST['lastname'], "text"),
                       GetSQLValueString($_POST['middlename'], "text"),
                       GetSQLValueString($_POST['address'], "text"),
                       GetSQLValueString($_POST['birthday'], "text"),
                       GetSQLValueString($_POST['contact'], "text"),
                       GetSQLValueString($_POST['email'], "text"));

  mysql_select_db($database_User_Information, $User_Information);
  $Result1 = mysql_query($insertSQL, $User_Information) or die(mysql_error());

  $insertGoTo = "success.php";
  if (isset($_SERVER['QUERY_STRING'])) {
    $insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
    $insertGoTo .= $_SERVER['QUERY_STRING'];
  }
  header(sprintf("Location: %s", $insertGoTo));
}

mysql_select_db($database_User_Information, $User_Information);
$query_User_Request = "SELECT * FROM users";
$User_Request = mysql_query($query_User_Request, $User_Information) or die(mysql_error());
$row_User_Request = mysql_fetch_assoc($User_Request);
$totalRows_User_Request = mysql_num_rows($User_Request);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Welcome to Student Attendance Monitoring System</title>
<link href="design.css" rel="stylesheet" type="text/css" />
</head>

<body>
<table width="900" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td align="left" valign="top" class="whiteBg"><table width="100%" border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td align="left" valign="top" class="bannerBg"><table width="870" border="0" align="right" cellpadding="0" cellspacing="0">
          <tr>
            <td width="206" align="left" valign="top" class="logoBotmbg"><table width="100%" border="0" cellspacing="0" cellpadding="0">
              <tr>
                <td align="left" valign="top" class="logoTopbg">&nbsp;</td>
              </tr>
              <tr>
                <td align="center" valign="top"><a href="index.html"><img src="images/logo.jpg" alt="Business" title="Business" width="169" height="111" border="0" /></a></td>
              </tr>
            </table></td>
            <td align="left" valign="top"><table width="100%" border="0" cellspacing="0" cellpadding="0">
              <tr>
                <td align="left" valign="top">
					<ul class="topMenu">
						<li><a href="home.php" title="Home" >Home</a></li>
						<li><a href="about.php" title="About Us" >About Us</a></li>
					
						<li><a href="news.php" title="News">News</a></li>
						<li><a href="contact.php" title="Contact Us" >Contact Us</a></li>
                        <li><a href="login.php" title="Login" class="active">Login</a></li>
					</ul>
				</td>
              </tr>
              <tr>
                <td align="left" valign="top" class="banner"><h2>Student Attendance Monitoring System</h2></td>
              </tr>
            </table></td>
          </tr>
        </table></td>
      </tr>
      <tr>
      <td align="left" valign="top" class="paddingTop30"><h1>Registration</h1>
      <p>&nbsp;</p>
       <form method="POST" action="<?php echo $editFormAction; ?>" name="form" >
       <label>Username:<br /></label>
<input type="text" name="username" required="required" />
<br />
Password:<br />
<input type="password" name="password"  required="required" />
<br />
Confirm Password:<br />
<input type="password" name="cpassword"  required="required" //>
<br />
Firstname:<br />
<input type="text" name="firstname"  required="required"  />
<br />
Lastname:<br />
<input type="text" name="lastname"  required="required" />
<br />
Middlename:<br />
<input type="text" name="middlename"  required="required" />
<br />
Address:<br />
<input type="text" name="address" />
<br />
Birthday:<br />
<input type="date" name="birthday" required="required"/>
<br />
Email:<br />
<input type="text" name="email" required="required"/>
<br />
Contact No.:<br />
<input type="text" name="contact" />
  <p>&nbsp;</p>
<input type = "submit" value = "Register"   style="height:40px; width:130px" />
<input type="hidden" name="MM_insert" value="form" />
       </form>
Already have an account? <br/>
<a href = "login.php">LOGIN NOW!!</a>
        </p>
        <p>&nbsp;</p>
        <p>&nbsp;</p>
        <p>Asia Pacific College <br />
        SS111 Software Development Project </p>
        <table width="842" border="0" align="center" cellpadding="0" cellspacing="0">
          <tr>
           
           
          </tr>
        </table>
      </tr>
    </table>
   </td>
  </tr>
  <tr>
    <td align="left" valign="top" class="footerBg">
		<table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td align="left" valign="top">
		<ul class="footerLink">
				
			
			<p class="copy">&copy; APC-Student Attendance Monitoring System. All Rights Reserved.</p>
            </ul>
			<p class="dsign">&nbsp;</p>
	</td>
  </tr>
</table>
	
	</td>
  </tr>
</table>
</body>
</html>
<?php
mysql_free_result($User_Request);
?>
